' sanity check
if WScript.Arguments.Count < 2 then
	WScript.quit
end if

infilename=WScript.Arguments.Item(0)
variablename=WScript.Arguments.Item(1)

' create file system object
set fso=CreateObject("Scripting.FileSystemObject")

' collapse backslashes and convert slashes to backslashes
infilename=replace(infilename,"\\","\",1,-1,0)
infilename=replace(infilename,"/","\",1,-1,0)

' open the file
set infile=fso.OpenTextFile(infilename)

fso.GetStandardStream(1).WriteLine("static const char *" & variablename & "[]={")

Do Until infile.AtEndOfStream

	' read the file line-by-line
	ln=infile.ReadLine()

	' make replacements
	ln=replace(ln,"\","\\",1,-1,0)
	ln=replace(ln,"""","\""",1,-1,0)

	' prepend and append double-quotes and a comma
	ln="""" & ln & ""","

	' write the line to stdout
	fso.GetStandardStream(1).WriteLine(ln)
Loop

fso.GetStandardStream(1).WriteLine("NULL")
fso.GetStandardStream(1).WriteLine("};")
